package com.mc.read.adminapi.service;

import com.mc.read.adminapi.manager.PublicManager;
import com.mc.read.common.emun.ServiceCodeEnum;
import com.mc.read.common.exception.ServiceException;
import com.mc.read.vo.respose.BaseRespose;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;

/**
 * @author liuhao
 * @date 2019/6/15 10:52
 */
@Service
@Slf4j
public class PublicService {
    @Autowired
    PublicManager publicManager;

    /**
     * @Author:LiuHao
     * @Date:15:24 2019/5/31
     * 增加下载记录 addDownload
     **/
    public BaseRespose addDownload(HttpServletRequest request) {
        log.info("添加下载记录");
        BaseRespose baseRespose = new BaseRespose();
        try {
            baseRespose = publicManager.addDownload(request);
        } catch (ServiceException e) {
            e.printStackTrace();
            log.error("增加下载记录 异常，异常编号{}，异常代码{}", e.getcode(), e.getMessage());
            baseRespose.setCode(e.getcode());
            baseRespose.setDisp(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            log.error("增加下载记录 错误，{}", e);
            baseRespose.setCode(ServiceCodeEnum.FAIL.getCode());
            baseRespose.setDisp(ServiceCodeEnum.FAIL.getDesc());
        }
        return baseRespose;
    }


}
